import fetch from '@/common/utils/http'

interface roleListData {
  type: string
  page: number
  limit: number
}

interface addRole {
  name: string
  type: string
  description: string
  settings: object
  limits: string[]
  functions: string[]
  dataScope: object[]
}

interface updateRole {
  _id: string
  name: string
  type: string
  description: string
  settings: object
  limits: string[]
  functions: string[]
  dataScope: object[]
}

interface deleteRole {
  _id: string
}

/* sku */
export const getAccountSku = () =>
  fetch({
    url: '/platform/action/console/limit/account',
    method: 'GET',
    params: {}
  })

/* 系统级别的权限模板 */
export const getRoleSystem = () =>
  fetch({
    url: '/platform/action/console/limit/system',
    method: 'GET',
    params: {}
  })

/* 系统角色设置项 */
export const getRoleSettiingItem = () =>
  fetch({
    url: '/platform/action/console/limit/setting-item',
    method: 'GET',
    params: {}
  })

/* 角色列表 */
export const getRoleList = (data: roleListData) =>
  fetch({
    url: '/platform/action/console/roles/query',
    method: 'POST',
    data: data
  })

/* 新建角色 */
export const addRole = (data: addRole) =>
  fetch({
    url: '/platform/action/console/roles/create',
    method: 'POST',
    data: data
  })

/* 编辑角色 */
export const updateRole = (data: updateRole) =>
  fetch({
    url: '/platform/action/console/roles/update',
    method: 'POST',
    data: data
  })

/* 删除角色 */
export const deleteRole = (data: deleteRole) =>
  fetch({
    url: '/platform/action/console/roles/delete',
    method: 'POST',
    data: data
  })
